package acwing.模拟;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * 航班时间
 *
 * @author yang
 * @date 2021/11/26
 */
public class 航班时间 {
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    public static void main(String[] args) throws Exception {

        int n = Integer.parseInt(br.readLine());
        while (n-- > 0) {
            int time = (get_time() + get_time()) /2 ;
            int hour = time / 3600;
            int minute = time % 3600 / 60;
            int sec = time % 60;
            System.out.printf("%02d:%02d:%02d" , hour , minute ,sec);
            System.out.println();
        }
    }

    public static int get_time() throws IOException {
        String str = br.readLine();
        int day = 0;

        if (str.charAt(str.length() - 1) == ')') {
            day = Integer.parseInt(""+str.charAt(str.length()-2));
            str = str.substring(0, str.length()-5);
        }
        String s[]=str.split(" ");
        String s1[]=s[0].split(":");
        String s2[]=s[1].split(":");
        int a1 = Integer.parseInt(s1[0]);
        int a2 = Integer.parseInt(s1[1]);
        int a3 = Integer.parseInt(s1[2]);
        int b1 = Integer.parseInt(s2[0]);
        int b2 = Integer.parseInt(s2[1]);
        int b3 = Integer.parseInt(s2[2]);
        return getSecond(b1, b2, b3) - getSecond(a1, a2, a3) + day * 24 * 3600;
    }

    private static int getSecond(int h1, int m1, int sc1) {
        return h1 * 3600 + m1 * 60 + sc1;
    }
}
